vec2 fixuv(in vec2 uv){
    vec2 p=10.*vec2(uv.x/iResolution.x*(iResolution.x/iResolution.y),abs(uv.y/iResolution.y-1.));
    return p;
}

vec3 drawGrid(in vec2 p){
    float f=floor(p.x)+floor(p.y);
    vec3 col=mix(vec3(.75),vec3(.3),smoothstep(0.,1.,mod(f,2.)));
    return col;
}

// 画中心线
vec3 drawCenterLine(in vec2 p,in vec3 col){
    p=(2.*p-iResolution.xy)/min(iResolution.x,iResolution.y);
    col=mix(col,vec3(1.,0.,0.),smoothstep(abs(p.x),abs(p.x),fwidth(p.x)*2.));
    col=mix(col,vec3(0.,0.,1.),smoothstep(abs(p.y),abs(p.y),fwidth(p.y)*2.));
    return col;
}

vec3 test(in vec2 p){
    vec3 col;
    vec2 uv=p;
    
    uv=uv*2.-1.;
    
    float m=.3137;
    float n=.5321;
    float t=iTime*300.;
    float x=sin(m*t);
    float y=cos(n*t);
    
    float c=distance(vec2(x,y),uv);
    c=smoothstep(.98,.999,1.-c);
    col=vec3(c);
    return col;
}

void mainImage(out vec4 fragColor,in vec2 fragCoord){
    vec2 p=fixuv(fragCoord);
    vec3 col=drawGrid(p);
    col=drawCenterLine(fragCoord,col);
    col=test(p);
    fragColor=vec4(col,1.);
}
